#include <stdio.h>
#include <windows.h>
 
int main(void) {
	HKEY hKey=0;
	char buf[255]={0};
	DWORD dwType=0;
	DWORD dwBufSize=sizeof(buf);
	const char* subkey="Software\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon";
	// Open the above defined registry key
  	if(RegOpenKey(HKEY_LOCAL_MACHINE,subkey,&hKey) == ERROR_SUCCESS) {
	  	dwType = REG_SZ;
	  	if( RegQueryValueEx(hKey,"DefaultUserName",0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS) {
		  	// Gather the value
		  	printf("key value is '%s\n",buf);
		}
		// otherwise report the failure :(
		else  printf("can not query for key value\n");
		RegCloseKey(hKey);
	}
	else printf("Can not open key\n");
	return 0;
}